package com.contact.view;

import android.app.Activity;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import com.contact.R;
import com.contact.bean.ContactBean;
import com.google.zxing.WriterException;
import com.zxing.encoding.EncodingHandler;

public class ContactDetailActivity extends Activity {
	
	public static ContactBean contactBean;
	private TextView tv_name, tv_number;
	private ImageView iv_qr_image;
	
	public void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		setContentView(R.layout.contact_detail);
		
		tv_name = (TextView)findViewById(R.id.tv_name);
		tv_number = (TextView)findViewById(R.id.tv_number);
		iv_qr_image = (ImageView)findViewById(R.id.iv_qr_image);
		
		tv_name.setText(contactBean.getDisplayName());
		tv_number.setText(contactBean.getPhoneNum());
		//根据字符串生成二维码图片并显示在界面上，第二个参数为图片的大小（400*400）
		String contentString = contactBean.getDisplayName() + ":" + contactBean.getPhoneNum();
		Bitmap qrCodeBitmap = null;
		try
		{
			qrCodeBitmap = EncodingHandler.createQRCode(contentString, 300);
			iv_qr_image.setImageBitmap(qrCodeBitmap);
		} catch (WriterException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}
}
